package dht.message;
import dht.*;

import java.nio.ByteBuffer;

public final class MessageUtils {
	
	public static Message createMessage(byte[] m, HostAddress sender) 
        {
		Message message = null;
		OpCode opCode = Message.getOpCodeFromBytes(m);
		switch (opCode) {
			case PrepareRequest :
				message = new PrepareRequestMessage(m, sender);
				break;
			case PrepareResponse :
				message = new PrepareResponseMessage(m, sender);
				break;
			case AcceptRequest :
				message = new AcceptRequestMessage(m, sender);
				break;
			case AcceptResponse :
				message = new AcceptResponseMessage(m, sender);
				break;
			default : break;
		}
		return message;
	}

}
